package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.MenuDao;
import com.itheima.pojo.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = MenuService.class)
@Transactional
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuDao menuDao;

    @Override
    public List<Menu> findAll() {
        List<Menu> list = menuDao.findParent();
        if (list != null || list.size() > 0) {
            for (Menu menu : list) {
                List<Menu> list_zi = menuDao.findCheil(menu.getId());
                menu.setChildren(list_zi);
            }
        }
        return list;
    }
}
